
var fs = require('fs');

fs.readFile('01_Nodejs/01_code/json.json','utf8', function(err, data) {
    console.log(data);

    var arr = JSON.parse(data);
    var newArr = [];
    for (let i = 0; i < arr.length; i++){
        if(arr[i].id != 2){
            newArr.push(arr[i]);;
        } 
    }

    var newJson =  JSON.stringify(newArr);
    fs.writeFile('01_Nodejs/01_code/json.json', newJson, function(err,data){
        console.log(data);
        console.log('删除成功！');
    })
})